/**
 * Created with IntelliJ IDEA.
 * User: chenkaiyu
 * Date: 15-5-26
 * Time: 下午7:05
 * To change this template use File | Settings | File Templates.
 */

var Gasogene = function () {

    var SodaParameter = {
        E3: $("#E3"),
        E4: $("#E4"),
        E5: $("#E5"),
        E6: $("#E6"),
        E7: $("#E7"),
        E8: $("#E8"),
        E9: $("#E9"),
        E10: $("#E10"),
        E11: $("#E11"),
        E12: $("#E12"),
        E13: $("#E13"),
        E14: $("#E14"),
        E15: $("#E15"),
        E16: $("#E16"),
        E17: $("#E17"),
        E18: $("#E18"),
        E19: $("#E19"),
        E20: $("#E20"),
        E21: $("#E21"),
        E22: $("#E22"),
        E23: $("#E23"),
        E24: $("#E24"),
        E25: $("#E25"),
        E26: $("#E26"),
        E27: $("#E27"),
        E29: $("#E29"),
        E30: $("#E30")
    };

    function showBlockUI(message, obj) {
        Metronic.blockUI({
            target: obj,
            boxed: false,
            message: message
        });
    }

    function calculateE6() {
        if ($.isNumeric(SodaParameter.E4.val()) && $.isNumeric(SodaParameter.E5.val()))
            $.ajax({
                url: basePath + "boiler/gasogene/calculateE6",
                type: "post",
                dataType: "json",
                data: $.param({E4: SodaParameter.E4.val(), E5: SodaParameter.E5.val()}),
                success: function (data) {
                    SodaParameter.E6.val(data);
                    Metronic.unblockUI(SodaParameter.E6.closest(".form-group"))

                }
            }).then(
                null,
                null,
                showBlockUI("计算中", SodaParameter.E6.closest(".form-group"))
            );
    }

    function calculateE9() {
        if ($.isNumeric(SodaParameter.E7.val()) && $.isNumeric(SodaParameter.E8.val()))
            $.ajax({
                url: basePath + "boiler/gasogene/calculateE9",
                type: "post",
                dataType: "json",
                data: $.param({E7: SodaParameter.E7.val(), E8: SodaParameter.E8.val()}),
                success: function (data) {
                    SodaParameter.E9.val(data);
                    Metronic.unblockUI(SodaParameter.E9.closest(".form-group"));
                }
            }).then(
                null,
                null,
                showBlockUI("计算中", SodaParameter.E9.closest(".form-group"))
            );
    }

    function calculateE12() {
        if ($.isNumeric(SodaParameter.E10.val()) && $.isNumeric(SodaParameter.E11.val()))
            $.ajax({
                url: basePath + "boiler/gasogene/calculateE12",
                type: "post",
                dataType: "json",
                data: $.param({E10: SodaParameter.E10.val(), E11: SodaParameter.E11.val()}),
                success: function (data) {
                    SodaParameter.E12.val(data);
                    Metronic.unblockUI(SodaParameter.E12.closest(".form-group"))
                }
            }).then(
                null,
                null,
                showBlockUI("计算中", SodaParameter.E12.closest(".form-group"))
            );
    }

    function calculateE16() {
        if ($.isNumeric(SodaParameter.E14.val()) && $.isNumeric(SodaParameter.E15.val()))
            $.ajax({
                url: basePath + "boiler/gasogene/calculateE16",
                type: "post",
                dataType: "json",
                data: $.param({E14: SodaParameter.E14.val(), E15: SodaParameter.E15.val()}),
                success: function (data) {
                    SodaParameter.E16.val(data);
                    Metronic.unblockUI(SodaParameter.E16.closest(".form-group"))
                }
            }).then(
                null,
                null,
                showBlockUI("计算中", SodaParameter.E16.closest(".form-group"))
            );
    }

    function calculateE19() {
        if ($.isNumeric(SodaParameter.E17.val()) && $.isNumeric(SodaParameter.E18.val()))
            $.ajax({
                url: basePath + "boiler/gasogene/calculateE19",
                type: "post",
                dataType: "json",
                data: $.param({E17: SodaParameter.E17.val(), E18: SodaParameter.E18.val()}),
                success: function (data) {
                    SodaParameter.E19.val(data);
                    Metronic.unblockUI(SodaParameter.E19.closest(".form-group"))
                }
            }).then(
                null,
                null,
                showBlockUI("计算中", SodaParameter.E19.closest(".form-group"))
            );
    }

    function calculateE23() {
        if ($.isNumeric(SodaParameter.E21.val()) && $.isNumeric(SodaParameter.E22.val()))
            $.ajax({
                url: basePath + "boiler/gasogene/calculateE23",
                type: "post",
                dataType: "json",
                data: $.param({E21: SodaParameter.E21.val(), E22: SodaParameter.E22.val()}),
                success: function (data) {
                    SodaParameter.E23.val(data);
                    Metronic.unblockUI(SodaParameter.E23.closest(".form-group"))
                }
            }).then(
                null,
                null,
                showBlockUI("计算中", SodaParameter.E23.closest(".form-group"))
            );
    }

    function calculateE27() {
        if ($.isNumeric(SodaParameter.E25.val()) && $.isNumeric(SodaParameter.E26.val()))
            $.ajax({
                url: basePath + "boiler/gasogene/calculateE27",
                type: "post",
                dataType: "json",
                data: $.param({E25: SodaParameter.E25.val(), E26: SodaParameter.E26.val()}),
                success: function (data) {
                    SodaParameter.E27.val(data);
                    Metronic.unblockUI(SodaParameter.E27.closest(".form-group"))
                }
            }).then(
                null,
                null,
                showBlockUI("计算中", SodaParameter.E27.closest(".form-group"))
            );
    }

    function calculateE30() {
        if ($.isNumeric(SodaParameter.E3.val()) && $.isNumeric(SodaParameter.E29.val()))
            $.ajax({
                url: basePath + "boiler/gasogene/calculateE30",
                type: "post",
                dataType: "json",
                data: $.param({E3: SodaParameter.E3.val(), E29: SodaParameter.E29.val()}),
                success: function (data) {
                    SodaParameter.E30.val(data);
                    Metronic.unblockUI(SodaParameter.E30.closest(".form-group"));
                }
            }).then(
                null,
                null,
                showBlockUI("计算中", SodaParameter.E30.closest(".form-group"))
            );
    }

    return {
        init: function () {
            $("#E3").blur(function () {
                var $obj = $("#E3");
                var E3 = $obj.val();
                validate.init($obj);

                if (validate.isNotNumber(E3)) {
                    validate.invalid();
                    return;
                }
                validate.valid();
                $.ajax({
                    url: basePath + "boiler/gasogene/saveTheValueOfE3",
                    dataType: "json",
                    type: "post",
                    data: "E3=" + E3
                }).done(calculateE30());

            });

            $("#E4").blur(function () {
                var $obj = $("#E4");
                var E4 = $obj.val();
                validate.init($obj);

                if (validate.isNotNumber(E4)) {
                    validate.invalid();
                    return;
                }
                validate.valid();
                $.ajax({
                    url: basePath + "boiler/gasogene/saveTheValueOfE4",
                    dataType: "json",
                    type: "post",
                    data: "E4=" + E4
                }).done(calculateE6())
            });

            $("#E5").blur(function () {
                var $obj = $("#E5");
                var E5 = $obj.val();
                validate.init($obj);

                if (validate.isNotNumber(E5)) {
                    validate.invalid();
                    return;
                }
                validate.valid();
                $.ajax({
                    url: basePath + "boiler/gasogene/saveTheValueOfE5",
                    dataType: "json",
                    type: "post",
                    data: "E5=" + E5
                }).done(calculateE6())
            });

            $("#E6").blur(function () {
                var $obj = $("#E6");
                var E6 = $obj.val();
                validate.init($obj);

                if (validate.isNotNumber(E6)) {
                    validate.invalid();
                    return;
                }
                validate.valid();
                $.ajax({
                    url: basePath + "boiler/gasogene/saveTheValueOfE6",
                    dataType: "json",
                    type: "post",
                    data: "E6=" + E6
                })

            });

            $("#E7").blur(function () {
                var $obj = $("#E7");
                var E7 = $obj.val();
                validate.init($obj);

                if (validate.isNotNumber(E7)) {
                    validate.invalid();
                    return;
                }
                validate.valid();
                $.ajax({
                    url: basePath + "boiler/gasogene/saveTheValueOfE7",
                    dataType: "json",
                    type: "post",
                    data: "E7=" + E7
                }).done(calculateE9())

            });

            $("#E8").blur(function () {
                var $obj = $("#E8");
                var E8 = $obj.val();
                validate.init($obj);


                if (validate.isNotNumber(E8)) {
                    validate.invalid();
                    return;
                }
                validate.valid();
                $.ajax({
                    url: basePath + "boiler/gasogene/saveTheValueOfE8",
                    dataType: "json",
                    type: "post",
                    data: "E8=" + E8
                }).done(calculateE9())

            });

            $("#E9").blur(function () {
                var $obj = $("#E9");
                var E9 = $obj.val();
                validate.init($obj);

                if (validate.isNotNumber(E9)) {
                    validate.invalid();
                    return;
                }
                validate.valid();
                $.ajax({
                    url: basePath + "boiler/gasogene/saveTheValueOfE9",
                    dataType: "json",
                    type: "post",
                    data: "E9=" + E9
                })

            });

            $("#E13").blur(function () {
                var $obj = $("#E13");
                var E13 = $obj.val();
                validate.init($obj);

                if (validate.isNotNumber(E13)) {
                    validate.invalid();
                    return;
                }
                validate.valid();
                $.ajax({
                    url: basePath + "boiler/gasogene/saveTheValueOfE13",
                    dataType: "json",
                    type: "post",
                    data: "E13=" + E13
                })

            });

            $("#E14").blur(function () {
                var $obj = $("#E14");
                var E14 = $obj.val();
                validate.init($obj);

                if (validate.isNotNumber(E14)) {
                    validate.invalid();
                    return;
                }
                validate.valid();
                $.ajax({
                    url: basePath + "boiler/gasogene/saveTheValueOfE14",
                    dataType: "json",
                    type: "post",
                    data: "E14=" + E14
                }).done(calculateE16())

            });

            $("#E15").blur(function () {
                var $obj = $("#E15");
                var E15 = $obj.val();
                validate.init($obj);

                if (validate.isNotNumber(E15)) {
                    validate.invalid();
                    return;
                }
                validate.valid();
                $.ajax({
                    url: basePath + "boiler/gasogene/saveTheValueOfE15",
                    dataType: "json",
                    type: "post",
                    data: "E15=" + E15
                }).done(calculateE16())


            });

            $("#E16").blur(function () {
                var $obj = $("#E16");
                var E16 = $obj.val();
                validate.init($obj);


                if (validate.isNotNumber(E16)) {
                    validate.invalid();
                    return;
                }
                validate.valid();
                $.ajax({
                    url: basePath + "boiler/gasogene/saveTheValueOfE16",
                    dataType: "json",
                    type: "post",
                    data: "E16=" + E16
                })

            });

            $("#E17").blur(function () {
                var $obj = $("#E17");
                var E17 = $obj.val();
                validate.init($obj);


                if (validate.isNotNumber(E17)) {
                    validate.invalid();
                    return;
                }
                validate.valid();
                $.ajax({
                    url: basePath + "boiler/gasogene/saveTheValueOfE17",
                    dataType: "json",
                    type: "post",
                    data: "E17=" + E17
                }).done(calculateE19())

            });

            $("#E18").blur(function () {
                var $obj = $("#E18");
                var E18 = $obj.val();
                validate.init($obj);


                if (validate.isNotNumber(E18)) {
                    validate.invalid();
                    return;
                }
                validate.valid();
                $.ajax({
                    url: basePath + "boiler/gasogene/saveTheValueOfE18",
                    dataType: "json",
                    type: "post",
                    data: "E18=" + E18
                }).done(calculateE19())

            });

            $("#E19").blur(function () {
                var $obj = $("#E19");
                var E19 = $obj.val();
                validate.init($obj);


                if (validate.isNotNumber(E19)) {
                    validate.invalid();
                    return;
                }
                validate.valid();
                $.ajax({
                    url: basePath + "boiler/gasogene/saveTheValueOfE19",
                    dataType: "json",
                    type: "post",
                    data: "E19=" + E19
                })

            });

            $("#E10").blur(function () {
                var $obj = $("#E10");
                var E10 = $obj.val();
                validate.init($obj);

                if (validate.isNotNumber(E10)) {
                    validate.invalid();
                    return;
                }
                validate.valid();
                $.ajax({
                    url: basePath + "boiler/gasogene/saveTheValueOfE10",
                    dataType: "json",
                    type: "post",
                    data: "E10=" + E10
                }).done(calculateE12())

            });

            $("#E11").blur(function () {
                var $obj = $("#E11");
                var E11 = $obj.val();
                validate.init($obj);


                if (validate.isNotNumber(E11)) {
                    validate.invalid();
                    return;
                }
                validate.valid();
                $.ajax({
                    url: basePath + "boiler/gasogene/saveTheValueOfE11",
                    dataType: "json",
                    type: "post",
                    data: "E11=" + E11
                }).done(calculateE12())

            });

            $("#E12").blur(function () {
                var $obj = $("#E12");
                var E12 = $obj.val();
                validate.init($obj);


                if (validate.isNotNumber(E12)) {
                    validate.invalid();
                    return;
                }
                validate.valid();
                $.ajax({
                    url: basePath + "boiler/gasogene/saveTheValueOfE12",
                    dataType: "json",
                    type: "post",
                    data: "E12=" + E12
                })
            });

            $("#E20").blur(function () {
                var $obj = $("#E20");
                var E20 = $obj.val();
                validate.init($obj);

                if (validate.isNotNumber(E20)) {
                    validate.invalid();
                    return;
                }
                validate.valid();
                $.ajax({
                    url: basePath + "boiler/gasogene/saveTheValueOfE20",
                    dataType: "json",
                    type: "post",
                    data: "E20=" + E20
                })

            });

            $("#E21").blur(function () {
                var $obj = $("#E21");
                var E21 = $obj.val();
                validate.init($obj);

                if (validate.isNotNumber(E21)) {
                    validate.invalid();
                    return;
                }
                validate.valid();
                $.ajax({
                    url: basePath + "boiler/gasogene/saveTheValueOfE21",
                    dataType: "json",
                    type: "post",
                    data: "E21=" + E21
                }).done(calculateE23())

            });

            $("#E22").blur(function () {
                var $obj = $("#E22");
                var E22 = $obj.val();
                validate.init($obj);

                if (validate.isNotNumber(E22)) {
                    validate.invalid();
                    return;
                }
                validate.valid();
                $.ajax({
                    url: basePath + "boiler/gasogene/saveTheValueOfE22",
                    dataType: "json",
                    type: "post",
                    data: "E22=" + E22
                }).done(calculateE23())

            });

            $("#E23").blur(function () {
                var $obj = $("#E23");
                var E23 = $obj.val();
                validate.init($obj);

                if (validate.isNotNumber(E23)) {
                    validate.invalid();
                    return;
                }
                validate.valid();
                $.ajax({
                    url: basePath + "boiler/gasogene/saveTheValueOfE23",
                    dataType: "json",
                    type: "post",
                    data: "E23=" + E23
                })
            });

            $("#E24").blur(function () {
                var $obj = $("#E24");
                var E24 = $obj.val();
                validate.init($obj);


                if (validate.isNotNumber(E24)) {
                    validate.invalid();
                    return;
                }
                validate.valid();
                $.ajax({
                    url: basePath + "boiler/gasogene/saveTheValueOfE24",
                    dataType: "json",
                    type: "post",
                    data: "E24=" + E24
                })

            });

            $("#E25").blur(function () {
                var $obj = $("#E25");
                var E25 = $obj.val();
                validate.init($obj);

                if (validate.isNotNumber(E25)) {
                    validate.invalid();
                    return;
                }
                validate.valid();
                $.ajax({
                    url: basePath + "boiler/gasogene/saveTheValueOfE25",
                    dataType: "json",
                    type: "post",
                    data: "E25=" + E25
                }).done(calculateE27())

            });

            $("#E26").blur(function () {
                var $obj = $("#E26");
                var E26 = $obj.val();
                validate.init($obj);

                if (validate.isNotNumber(E26)) {
                    validate.invalid();
                    return;
                }
                validate.valid();
                $.ajax({
                    url: basePath + "boiler/gasogene/saveTheValueOfE26",
                    dataType: "json",
                    type: "post",
                    data: "E26=" + E26
                }).done(calculateE27())

            });

            $("#E27").blur(function () {
                var $obj = $("#E27");
                var E27 = $obj.val();
                validate.init($obj);

                if (validate.isNotNumber(E27)) {
                    validate.invalid();
                    return;
                }
                validate.valid();
                $.ajax({
                    url: basePath + "boiler/gasogene/saveTheValueOfE27",
                    dataType: "json",
                    type: "post",
                    data: "E27=" + E27
                })

            });

            $("#E29").blur(function () {
                var $obj = $("#E29");
                var E29 = $obj.val();
                validate.init($obj);

                if (validate.isNotNumber(E29)) {
                    validate.invalid();
                    return;
                }
                validate.valid();
                $.ajax({
                    url: basePath + "boiler/gasogene/saveTheValueOfE29",
                    dataType: "json",
                    type: "post",
                    data: "E29=" + E29
                }).done(calculateE30());

            });

            $("#E30").blur(function () {
                var $obj = $("#E30");
                var E30 = $obj.val();
                validate.init($obj);

                if (validate.isNotNumber(E30)) {
                    validate.invalid();
                    return;
                }
                validate.valid();
                $.ajax({
                    url: basePath + "boiler/gasogene/saveTheValueOfE30",
                    dataType: "json",
                    type: "post",
                    data: "E30=" + E30
                })

            });

            $("#nextPage").on("click", function () {
                window.location.href = basePath + "boiler/airgas?menuId=19"
            })
        },

        recoverValueRevise: function () {
            $.each(SodaParameter, function (key, jqObj) {
                jqObj.val(getValidRecoverVal(jqObj.val()));
            })
        }
    }
}();
